# -!- coding: utf-8 -!-
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#作者：cacho_37967865
#博客：https://blog.csdn.net/sinat_37967865
#文件：dealLogs.py
#日期：2019-09-27
#备注：通过日志拿到相应数据，然后对数据进行分析
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

from pycacho.cachobase.file_deal import an_save_txt

# ['ERROR','错误']
in_words =[['错误消息[用户额度作废]','10004'],['表达式：','']]


def get_requireInfo(file_name,in_words):
    file = file_name + '.log'
    i = 0
    with open(file, 'r', encoding='utf-8') as logs:
        for line in logs.readlines():
            i = i + 1
            for word in in_words:
                if word[0] in line and word[1] in line:
                    new_line = line
                    new_line.lstrip()
                    print('第' + str(i) +'行：', new_line)
                    an_save_txt(file_name+'.txt',new_line)


if __name__ == '__main__':
    file_name = 'E:\zenglingwei\logs\\msydloan-web'
    get_requireInfo(file_name,in_words)          # ['接口文件不存在']


